/**
 * 
 */
package org.ChrisRiffle.Acme.BoundingBox.workers;

import java.util.logging.Logger;

import javax.swing.SwingWorker;

import org.ChrisRiffle.Acme.BoundingBox.controlers.AudioController;
import org.ChrisRiffle.Acme.BoundingBox.controlers.DataSetController;
import org.ChrisRiffle.Acme.BoundingBox.controlers.QueryDialogController;

/**
 * DataSetLoaderScreenProgressWorker
 * 
 * Initializes heavyweight non-gui stuff on a background 
 * thread, displays a 'loading' panel while it's doing that,
 * then displays the 'ready panel' once it's ready for user 
 * interaction
 * 
 * @author RIF
 */
public class AppInitializerWorker extends SwingWorker<Void, Void> {

	@Override
	protected Void doInBackground() throws Exception {
		
		Logger.getAnonymousLogger().info("Initializing DataSet Controller...");

		DataSetController.INSTANCE.init();
		
		Logger.getAnonymousLogger().info("Initializing Audio Player...");
		
		AudioController.INSTANCE.init();

		return null;
	}

	@Override
	protected void done() {

		// swap the 'loading' panel with the 'ready' panel
		QueryDialogController.INSTANCE.displayPanelType(QueryDialogController.PANEL_TYPE.READY);

	}

}
